<div class="content last ui-widget-content">
    <div class="content-full">
        <div style="width: 98%;padding-left: 5px;">
            <?php if (count($this->arrError) > 0) echo $this->error($this->arrError); ?>
            <div class="cms_table">
                <?php if ($this->Obj['isupdate'] == 0) { ?>
                    <h2> Thêm mới chủ đề môn học</h2>
                <?php } ?>
                <?php if ($this->Obj['isupdate'] == 1) { ?>
                    <h2>Chỉnh sửa thông tin chủ đề môn học</h2>
                <?php } ?>

                <form action="<?php echo BASE_URL; ?>/<?php echo $this->controller; ?>/<?php echo $this->action; ?>"	method="POST" name="quiz-form" id="" enctype="multipart/form-data">
                    <input type="hidden" name="id" value="<?php echo $this->Obj['id']; ?>">		
                    <input type="hidden" name="isupdate" value="<?php echo $this->Obj['isupdate']; ?>"/>			
                    <table cellpadding="0" cellspacing="0">
                        <tr><td class="label">
                                Tên chủ đề môn học: 
                            </td><td class="field_container"> 
                                <input type="text" name="name" style="width: 300px;" value="<?php echo $this->Obj['name']; ?>" >
                            </td></tr>
                        <tr><td class="label">
                                Môn học:  
                            </td><td class="field_container">
                                <?php echo $this->SltSubject("subject_id", $this->Obj['subject_id']); ?>
                            </td></tr>
                        <tr><td class="label">
                                Thứ tự xuất hiện:  
                            </td><td class="field_container">
                                <select name="stt">
                                    <?php
                                    for ($i = 1; $i < 100; $i++) {
                                        if (isset($this->Obj['stt'])) {
                                            if ($i == $this->Obj['stt']){
                                                echo "<option value='" . $i . "' selected='selected'>" . $i . "</option>";
                                            }
                                            else
                                            {
                                                echo "<option value='" . $i . "'>" . $i . "</option>";
                                            }
                                        }
                                        else
                                            echo "<option value='" . $i . "'>" . $i . "</option>";
                                    }
                                    ?>
                                </select>
                            </td></tr>

                        <tr><td class="label">
                                Nội dung PDF:  
                            </td><td class="field_container">
                                <input type="text" name="path" id="path" style="width: 300px;" value="<?php echo isset($this->Obj['path']) ? $this->Obj['path'] : ""; ?>" >
                                <input type="button" onclick="showUpload();" value="upload" class="add-answer-icon ui-state-default ui-corner-all"/>
                            </td>
                        </tr>


                        <tr><td colspan="2">
                                <p>
                                    <label>	Ghi chú:</label>
                                    <textarea class="chapter-subject-short-editor" name="note" rows="3" cols="20"><?php echo $this->Obj['note']; ?></textarea>
                                </p>
                            </td></tr>
                        <tr><td colspan="2"  style="font-size: 12px; color: white; font-family: tahoma;"  >
                                <p align="center">
                                    <input  type="submit" value="Đồng ý" style="font-size: 15px;" class="add-answer-icon ui-state-default ui-corner-all">&nbsp;&nbsp;&nbsp;&nbsp;
                                    <input  type="button" value="Hủy bỏ" onclick="window.location='<?php echo BASE_URL . '/chaptersubject'; ?>'" style="font-size: 15px;" class="add-answer-icon ui-state-default ui-corner-all">
                                </p>
                            </td></tr>

                    </table>		
                </form>
                <!--  -->
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function(){
        initEditorByClassShotcut("chapter-subject-short-editor",300,false,true)
    });
    function Upload(){
        var filename = $("#pdfFile").val();
        if (filename=="")
            alert("Chưa tải file");
        else{
            $.ajax({
                url: "<?php echo BASE_URL; ?>/<?php echo $this->controller; ?>/upload",
                type: "POST",
                dataType: "json",
                data: {pdf: filename},
                success: function(html){
                    alert(html);
                }
            });
        }
    }
</script>

<script type="text/javascript">
    function showUpload(){
        $("#pdffield").val('');
        $( "#dialog-upload" ).dialog(
        {modal: true,
          
            width: 500,
            height: 300,
            close: function(){
                var filename=$('#ifr').contents().find('input[name=pdfpath]').val();
                        if (filename != null){
                            $('#path').val(filename);
                        }
            },
            buttons: [{
                    text: "Đóng",
                    click: function () {
                         $( this ).dialog( "close" );
                    }
                }]
        }
    );
    }

    function uploadpdf(){
        $('#uploadForm').submit(function(e) {
            e.preventDefault();
            $.post('<?php echo BASE_URL; ?>/<?php echo $this->controller; ?>/upload', $('#uploadForm').serialize());
            return false
        });
    }
</script>

<div id="dialog-upload" title="Upload nội dung PDF" style="display: none">
    <iframe width="450" id="ifr" src="<?php echo BASE_URL; ?>/<?php echo $this->controller; ?>/upload"></iframe>
</div>